//
//  FFKVOProxy.h
//  FFMVVM
//
//  Created by 李魁峰 on 2016/12/6.
//  Copyright © 2016年 AKsoftware. All rights reserved.
//

#import <Foundation/Foundation.h>



#define FFKVOVMBindModel_M_I(viewModel, Class, toTarget, toKey,  ...)\
({\
__weak typeof(toTarget) weakToTarget = toTarget;\
NSString *realTokey = @keypath(toTarget, toKey);\
void (^blk)(NSString *key, id value) = ^(NSString *key, id value){\
[weakToTarget setValue:value forKey:realTokey];\
};\
FFKVOVMBindModel_M_B(viewModel,Class,blk, __VA_ARGS__);\
});


#define FFKVOVMBindModel_M_B(viewModel,Class,block, ...)\
({\
NSString *key1;\
NSMutableArray *keyArray = [[NSMutableArray alloc] init];\
metamacro_foreach_cxt(FFVMKeypath,,Class.new, __VA_ARGS__)\
[viewModel addBindObserver:self forkeyPathArray:keyArray options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld performQueue:dispatch_get_main_queue() performBlock:block];\
})





@interface FFKVOProxy : NSObject


@end
